import {query, update} from '@/services/strategy/process';

export default {
  namespace: 'process',

  state: {
    // 列表数据
    data: {
      dataList: [],
    }
  },

  effects: {
    * query({payload}, {call, put}) {
      const response = yield call(query, payload);
      console.info(" response.result:" + response.result);

      if (response.result == "ok") {
        console.info("---save ---");
        yield put({
          type: 'save',
          payload: response,
        });
      }else {
        alert(action.payload.msg)

      }



    },

    * update({payload, callback}, {call, put}) {
      const response = yield call(update, payload);
      // yield put({
      //   type: 'save',
      //   payload: response,
      // });
      if (callback) callback(response);
    },
  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload.data,
      };
    }
  },
};
